<!--
 * @FileDescription: 商家入住、注册页面
 * @Author: zsf
 * @Date: 2021-03-28 10:16:18
 * @LastEditors: zsf
 * @LastEditTime: 2021-03-29 21:15:18
-->
<template>
  <div class="agent-registration">
    <!-- 流程模块 -->
    <div class="left" v-if="!showRegist">
      <div class="title" style="margin-top:100px">商家入驻流程</div>
      <div class="cont">
        <div class="item">
          <img src="../../assets/img/a_1.png" alt="" />
          <div class="text">填写注册资料。</div>
          <i class="iconfont icon-xuxian"></i>
        </div>
        <div class="item">
          <img src="../../assets/img/a_2.png" alt="" />
          <div class="text">平台工作人员进行资格审核。</div>
          <i class="iconfont icon-xuxian"></i>
        </div>
        <div class="item">
          <img src="../../assets/img/a_3.png" alt="" />
          <div class="text">审核通过成为代理商。</div>
          <i class="iconfont icon-xuxian"></i>
        </div>
        <div class="item">
          <img src="../../assets/img/b_5.png" alt="" />
          <div class="text">发送试片订单邀请修片师试片。</div>
          <i class="iconfont icon-xuxian"></i>
        </div>
        <div class="item">
          <img src="../../assets/img/b_3.png" alt="" />
          <div class="text">试片满意，和修片师签订合作协议。</div>
          <i class="iconfont icon-xuxian"></i>
        </div>
        <div class="item">
          <img src="../../assets/img/b_4.png" alt="" />
          <div class="text">发送修片任务，指定合作中的修片师完成</div>
        </div>
        <div class="item">
          <a-button class="my-ant-purple-btn" @click="showRegist = true">立即注册</a-button>
        </div>
      </div>
    </div>

    <!-- 注册模块 -->
    <div class="left" v-else>
      <div class="title" style="margin-top:10px">商家账号注册</div>
      <div class="form">
        <a-form-model
          ref="ruleForm"
          :model="form"
          :rules="rules"
          :label-col="labelCol"
          :wrapper-col="wrapperCol"
        >
          <a-form-model-item label="手机号">
            <a-input v-model="form.phone" />
          </a-form-model-item>
          <a-form-model-item label="验证码">
            <a-row :gutter="8">
              <a-col :span="12">
                <a-input v-model="form.code" />
              </a-col>
              <a-col :span="12">
                <a-button class="my-ant-purple-btn">点击获取</a-button>
              </a-col>
            </a-row>
          </a-form-model-item>
          <a-form-model-item label="密码">
            <a-input v-model="form.password" />
          </a-form-model-item>
          <a-form-model-item label="确认密码">
            <a-input v-model="form.surePassword" />
          </a-form-model-item>
          <a-form-model-item label="姓名" prop="name">
            <a-input v-model="form.name" />
          </a-form-model-item>
          <a-form-model-item label="性别">
            <a-radio-group v-model="form.gender">
              <a-radio :value="1"> 男 </a-radio>
              <a-radio :value="2"> 女 </a-radio>
            </a-radio-group>
          </a-form-model-item>
          <a-form-model-item label="身份证号">
            <a-input v-model="form.identityNumber" />
          </a-form-model-item>
          <a-form-model-item label="身份证照">
            <a-row :gutter="8">
              <a-col :span="8">
                <a-upload
                  name="avatar"
                  list-type="picture-card"
                  class="avatar-uploader"
                  :show-upload-list="false"
                  action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
                  :before-upload="beforeUpload"
                  @change="handleChange"
                >
                  <img v-if="form.positiveImg" :src="form.positiveImg" alt="avatar" />
                  <div v-else>
                    <a-icon :type="positiveLoading ? 'loading' : 'plus'" />
                    <div class="ant-upload-text">上传正面</div>
                  </div>
                </a-upload>
              </a-col>
              <a-col :span="9">
                <a-upload
                  name="avatar"
                  list-type="picture-card"
                  class="avatar-uploader"
                  :show-upload-list="false"
                  action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
                  :before-upload="beforeUpload"
                  @change="handleChange"
                >
                  <img v-if="form.backImg" :src="form.backImg" alt="avatar" />
                  <div v-else>
                    <a-icon :type="backLoading ? 'loading' : 'plus'" />
                    <div class="ant-upload-text">上传背面</div>
                  </div>
                </a-upload>
              </a-col>
            </a-row>
            <a-row :gutter="8">
              <div class="warning">请确保身份证上信息清晰可辨，且照片小于5MB</div>
            </a-row>
          </a-form-model-item>
          <a-form-model-item label="身份地址">
            <a-input v-model="form.phone" />
          </a-form-model-item>
          <a-form-model-item label="营业执照">
            <a-upload
              name="avatar"
              list-type="picture-card"
              class="avatar-uploader"
              :show-upload-list="false"
              action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
              :before-upload="beforeUpload"
              @change="handleChange"
            >
              <img v-if="form.positiveImg" :src="form.positiveImg" alt="avatar" />
              <div v-else>
                <a-icon :type="positiveLoading ? 'loading' : 'plus'" />
                <div class="ant-upload-text">上传营业执照</div>
              </div>
            </a-upload>
            <a-row :gutter="8">
              <div class="warning">请确保营业执照上传信息清晰可辨，且照片小于5MB</div>
            </a-row>
          </a-form-model-item>
          <a-form-model-item label="商家名称" prop="name">
            <a-input v-model="form.name" />
          </a-form-model-item>
          <a-form-model-item label="注册地区">
            <a-cascader :options="areaOptions" @change="areaOnChange" />
          </a-form-model-item>
          <a-form-model-item label="门店地址" prop="name">
            <a-input v-model="form.name" />
          </a-form-model-item>
          <a-form-model-item label="邀请人手机号">
            <a-input v-model="form.inviterPhone" />
          </a-form-model-item>
          <a-form-model-item :wrapper-col="{ span: 10, offset: 6 }" class="sub-btn-cont">
            <a-button class="my-ant-gray-btn btn" @click="showRegist = false"> 取消 </a-button>
            <a-button class="my-ant-purple-btn btn" style="margin-left: 50px" type="primary" @click="onSubmit"> 提交 </a-button>
          </a-form-model-item>
        </a-form-model>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      labelCol: { span: 6 },
      wrapperCol: { span: 10 },
      showRegist: false,
      form: {
        phone: '',
        code: '',
        password: '',
        surePassword: '',
        name: '',
        gender: 1,
        identityNumber: '',
        positiveImg: '',
        backImg: '',
        identityAdress: '',
        inviterPhone: ''
      },
      positiveLoading: false,
      backLoading: false,
      areaOptions: [], // 地区数据
      rules: {
        name: [
          { required: true, message: 'Please input Activity name', trigger: 'blur' },
          { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
        ],
      },
    };
  },
  methods: {
    onSubmit() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          console.log('submit!!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm() {
      this.$refs.ruleForm.resetFields();
    },
    beforeUpload(file) {

    },
    handleChange(info) {

    },
    areaOnChange(value) {
      this.form.identityAdress = value;
    }
  },
};
</script>

<style lang="less" scoped>
.agent-registration {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  background: url("../../assets/img/b_1.png");
  background-repeat: no-repeat;
  background-size: 405px 280px;
  .left {
    flex: 0 0 800px;
    .title {
      width: 198px;
      height: 22px;
      margin-left:170px;
      font-size: 22px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      line-height: 37px;
      color: #343434;
      position: relative;
      &::before {
        content: '';
        width: 5px;
        height: 25px;
        background: #6E6EFE;
        position: absolute;
        left: -15px;
        top: 7px;
      }
    }
    .cont {
      display: flex;
      flex-direction: column;
      margin: 55px 0 0 150px;
      .item {
        display: flex;
        align-items: center;
        margin: 0 0 22px 0;
        position: relative;
        img {
          width: 84px;
          height: 84px;
        }
        .text {
          margin: 0 0 0 80px;
          font-size: 15px;
          color: #343434;
        }
        .my-ant-purple-btn {
          margin: 0 0 0 164px;
        }
        .icon-xuxian {
          position: absolute;
          left: 27px;
          bottom: -33px;
          font-size: 30px;
          transform: rotate(90deg);
        }
      }
    }

    .form {
      margin: 21px 0 0 0;
      .warning {
        font-size: 14px;
        color: #FF7C7C;
      }
      .sub-btn-cont {
        margin: 10px 0;
        /deep/ .ant-form-item-children {
          display: flex;
          justify-content: space-between;
        }
        .btn {
          width: 154px;
        }
      }
    }
  }
  .ant-form-item {
    margin-bottom: 0px;
  }
  /deep/.ant-radio-inner::after {
    background-color: #6E6EFE;
  }
  /deep/.ant-radio-checked .ant-radio-inner {
    border-color: #6E6EFE;
  }
}
</style>